﻿namespace WMS6.Web.GlobalControl
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.OutboundDetailServiceRef;
    using WMS6.Web.UserControls;

    public class WarehouseTransferDetail : BasePage
    {
        protected Button btnGoBack;
        protected HtmlForm F13513;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HiddenField hdnExpiryDate;
        protected HiddenField hdnExternal;
        protected HiddenField hdnIntransitID;
        protected HiddenField hdnLot1;
        protected HiddenField hdnLot10;
        protected HiddenField hdnLot2;
        protected HiddenField hdnLot3;
        protected HiddenField hdnLot4;
        protected HiddenField hdnLot5;
        protected HiddenField hdnLot6;
        protected HiddenField hdnLot7;
        protected HiddenField hdnLot8;
        protected HiddenField hdnLot9;
        protected HiddenField hdnOwnerID;
        protected HiddenField hdnProductDate;
        protected HiddenField hdnSrcDbID;
        protected HtmlInputHidden hdnType;
        protected Label lblAllocateRuleDetail;
        protected Label lblLineID;
        protected Label lblLotID;
        protected Label lblMsg;
        protected Label lblPackID;
        protected Label lblQty;
        protected Label lblReceivedQty;
        protected Label lblShippedQty;
        protected Label lblSkuID;
        protected Label lblUomID;
        protected LotAtrributeCtrl LotAtrributeCtrl1;
        protected HtmlLink mycss;
        protected Label one1;
        protected Label one2;
        protected ScriptManager ScriptManager1;
        protected TextBox txtLineID;
        protected TextBox txtLot;
        protected TextBox txtPackID;
        protected TextBox txtQty;
        protected TextBox txtReceivedQty;
        protected TextBox txtShippedQty;
        protected TextBox txtSkuID;
        protected TextBox txtUomID;

        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            base.Response.Redirect(string.Format("WarehouseTransfer.aspx?from=list&ID={0}&SrcDbID={1}", base.UrlEncode(this.hdnIntransitID.Value.Trim()), base.UrlEncode(this.hdnSrcDbID.Value.Trim())));
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["LineID"]))
            {
                this.txtLineID.Text = base.Request.QueryString["LineID"].ToString();
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["ID"]))
            {
                this.hdnIntransitID.Value = base.Request.QueryString["ID"].ToString();
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["SrcDbID"]))
            {
                this.hdnSrcDbID.Value = base.Request.QueryString["SrcDbID"].ToString();
            }
            this.hdnType.Value = "edit";
            this.SetIntransitDetail2From();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            base.InitPage(this.Page);
            this.LoadData();
            this.LotAtrributeCtrl1.LoadData(this.txtSkuID.Text, this.hdnOwnerID.Value, this.LotAtrributeCtrl1.ClientID, false, 4);
        }

        private void SetIntransitDetail2From()
        {
            if ((base.Request.QueryString["LineID"] != null) && (base.Request.QueryString["ID"] != null))
            {
                IntransitDetailInfo intransitDetailInfo = OutboundDetailServiceClientProxy.GetInstance().GetIntransitDetailInfoByID(this.hdnIntransitID.Value, this.txtLineID.Text, this.hdnSrcDbID.Value);
                if (intransitDetailInfo != null)
                {
                    this.txtSkuID.Text = intransitDetailInfo.SkuID;
                    this.txtUomID.Text = intransitDetailInfo.UomID;
                    this.txtPackID.Text = intransitDetailInfo.PackID;
                    this.txtQty.Text = base.GetPreferenceDigit(intransitDetailInfo.Qty);
                    this.txtShippedQty.Text = base.GetPreferenceDigit(intransitDetailInfo.ShippedQty);
                    this.txtReceivedQty.Text = base.GetPreferenceDigit(intransitDetailInfo.ReceivedQty);
                    this.txtLot.Text = intransitDetailInfo.ExternalLot;
                    this.hdnOwnerID.Value = intransitDetailInfo.OwnerID;
                    this.hdnLot1.Value = intransitDetailInfo.LotAttr01;
                    this.hdnLot2.Value = intransitDetailInfo.LotAttr02;
                    this.hdnLot3.Value = intransitDetailInfo.LotAttr03;
                    this.hdnLot4.Value = intransitDetailInfo.LotAttr04;
                    this.hdnLot5.Value = intransitDetailInfo.LotAttr05;
                    this.hdnLot6.Value = intransitDetailInfo.LotAttr06;
                    this.hdnLot7.Value = intransitDetailInfo.LotAttr07;
                    this.hdnLot8.Value = intransitDetailInfo.LotAttr08;
                    this.hdnLot9.Value = intransitDetailInfo.LotAttr09;
                    this.hdnLot10.Value = intransitDetailInfo.LotAttr10;
                    this.hdnProductDate.Value = base.GetPreferenceShortDate(intransitDetailInfo.ProduceDate);
                    this.hdnExpiryDate.Value = base.GetPreferenceShortDate(intransitDetailInfo.ExpiryDate);
                    this.hdnExternal.Value = intransitDetailInfo.ExternalLot;
                }
            }
        }
    }
}

